import { useState } from 'react';
import { ProTable as Table } from '@ant-design/pro-components';

import EmptyMsg from '@/components/EmptyMsg';

const ProTable = (props) => {
  const { ...tableProps } = props;
  const [errorValue, setErrorValue] = useState('');
  return (
    <Table
      revalidateOnFocus={false}
      options={false}
      onRequestError={(error) => {
        setErrorValue(error);
      }}
      locale={{
        emptyText: <EmptyMsg msg={errorValue} />,
      }}
      sticky={{ offsetHeader: '40px' }}
      {...tableProps}
    />
  );
};

export default ProTable;
